package com.wyh.recketmq.seckill.mq;

/**
 * @author peng
 * @description mq消息发送延迟级别
 * @date 2020/11/17 14:02 下午
 */
public enum DelayTimeLevel {

    SECONDS_ONE(1, "1s"),
    SECONDS_FIVE(2, "5s"),
    SECONDS_TEN(3, "10s"),
    SECONDS_THIRTY(4, "30s"),
    MINUTES_ONE(5, "1m"),
    MINUTES_TWO(6, "2m"),
    MINUTES_THREE(7, "3m"),
    MINUTES_FOUR(8, "4m"),
    MINUTES_FIVE(9, "5m"),
    MINUTES_SIX(10, "6m"),
    MINUTES_SEVEN(11, "7m"),
    MINUTES_ENGHT(12, "8m"),
    MINUTES_NINE(13, "9m"),
    MINUTES_TEN(14, "10m"),
    MINUTES_TWENTY(15, "20m"),
    MINUTES_THIRTY(16, "30m"),
    HOURS_ONE(17, "1h"),
    HOURS_TWO(18, "2h"),
    ;

    private int level;

    private String des;

    public int getLevel() {
        return level;
    }

    public String getDes() {
        return des;
    }

    DelayTimeLevel(int level, String des) {
        this.level = level;
        this.des = des;
    }

    public static DelayTimeLevel parse(int level) {
        DelayTimeLevel[] values = DelayTimeLevel.values();

        for (DelayTimeLevel delayTimeLevel : values) {
            if (level == delayTimeLevel.getLevel()) {
                return delayTimeLevel;
            }
        }
        return null;
    }
}
